// import axios from './contents/axios.js'
(function () {
    // 存草稿
    let boxone = document.querySelector(".popup-box>.box-one");
    let popupboxdiv = document.querySelector(".popup-box");
    let savedraft = document.querySelector(".save-draft");
    savedraft.onclick = function () {
        console.log(111);
        let title = document.querySelector(".input-title").value;
        let inputcircle = document.querySelector(".article-panel .circle .input>input").value;
        if (!title) {
            popupboxdiv.style.marginTop = 400 + 'px';
            boxone.innerText = "标题内容不能为空";
            popupboxdiv.style.opacity = 1;
            setTimeout(() => {
                popupboxdiv.style.opacity = 0;
            }, 3000);
            return;
        } else {
            popupboxdiv.style.marginTop = 400 + 'px';
            boxone.innerText = "存储成功";
            popupboxdiv.style.opacity = 1;
            setTimeout(() => {
                popupboxdiv.style.opacity = 0;
            }, 3000);
        }

        let issue = 0;
        axios.post('/api/publish', {
            title,
            cid: 1,
            content: html,
            issue
        }).then(function (res) {
            console.log(res);
            // window.location.href = './index.html';
        }).catch(function (error) {
            console.log(error);
        });
    }



    let drafta = document.querySelector(".draft-a")
    drafta.onclick = function () {
        console.log(111);
        window.location.href = './mypage.html';
    }

}
)();